import assign from 'object-assign';
import {observable, action} from 'mobx';
import axios from "axios";

class CurStore {
    @observable totalCount = 0;
    @observable page = 1;
    @observable size = 20;
    @observable hasNext = true;
    @observable data = [];
    @observable queryParams = {};
    constructor(props) {

    }
    @action getData(){
        axios.get('/studios/members/group/all_members', {
            params: assign({
                page: this.page++,
                size: this.size
            }, this.queryParams)
        }).then(response => {
            if (response.data.status == 200) {
                let rsData = response.data.data;
                this.totalCount = rsData.totalCount || 0;
                if(rsData.list && rsData.list.length){
                    this.data.push.apply(this.data,rsData.list);
                    this.hasNext = true;
                }else{
                    this.hasNext = false;
                }
            } else {
                this.hasNext = false;
            }
        }).catch(error => {
            console.error(error);
        }).then(() => {
            console.log("always executed");
        });
    }
}
export default CurStore;
